// map.js
import QQMap from '/miniprogram/utils/qqmap'
Page({
  // 不可包裹在对象里面，数据！！！！
  data: {
    id: '', // 报修详情的接口id
    latitude: 28.216207,
    longitude: 112.862157,
    iconPath: '/static/images/marker.png',
    markers: [
      {
        id: 1,
        latitude: 28.216207,
        longitude: 112.862157,
        width: 24,
        height: 30,
      },
      {
        id: 2,
        latitude: 28.216249,
        longitude: 112.860113,
        iconPath: '/static/images/marker.png',
        width: 40,
        height: 40,
      },
    ],
  },
  async onLoad({id}){
    // 设置页面经纬度
    // const {latitude , longitude} = await wx.getLocation()
    this.setData({
      id,
      // latitude,
      // longitude
    })
    this.queryRepairDetailInfo()
  },
  // 获取页面详情方法
  async queryRepairDetailInfo(){
    const {data} = await wx.http({
      method: 'GET',
      url: '/repair/'+ this.data.id,
    })
   this.setData({
    ...data
   })
  },
  // 跳转到修改页面
  goFormEdit(){
    wx.navigateTo({
      url: '/repair_pkg/pages/form-edit/index?id='+ this.data.id,
    })
  },
  // 取消报修
  async cancelRepair(){
    const res = await wx.http({
      url: '/cancel/repaire/'+ this.data.id,
      method: 'PUT'
    })
    // 回退一步
    wx.navigateBack()
  }
})
